# Maintainer: Alexander F. Rødseth <xyproto@archlinux.org>
# Contributor: Sergej Pupykin <pupykin.s+arch@gmail.com>
# Contributor: Vesa Kaihlavirta <vegai@iki.fi>
# Contributor: Philip Nilsson <pnilsson@nullref.se>

pkgname=alex
pkgver=3.2.7.3
pkgrel=1
pkgdesc='Lexical analyser generator for Haskell'
arch=(loong64 x86_64)
url='https://hackage.haskell.org/package/alex'
license=(BSD)
depends=(ghc-libs)
makedepends=(ghc happy)
source=("https://hackage.haskell.org/packages/archive/$pkgname/$pkgver/$pkgname-$pkgver.tar.gz")
sha512sums=('5bd6fa4c1964e3019e609d03cb0d93dcc5ca0d825a256ba190581ad7fdf9db6030e56b910ac7f8a2786d2051c4f6d8d61b950d584337465e82769aca85131293')

build() {
  cd $pkgname-$pkgver
  runghc Setup.hs configure \
    --prefix=/usr \
    --datasubdir=$pkgname \
    --enable-executable-dynamic \
    --ghc-option=-optl-Wl\,-z\,relro\,-z\,now \
    --ghc-option='-pie'
  runghc Setup.hs build
}

package() {
  cd $pkgname-$pkgver
  runghc Setup.hs copy --destdir="$pkgdir"
  install -Dm644 LICENSE "$pkgdir/usr/share/licenses/alex/BSD3"

  # Doc only contains the license
  rm -rf "$pkgdir/usr/share/doc"
}

# getver: hackage.haskell.org/package/alex/changelog
# vim: ts=2 sw=2 et:
